<?php

echo $this->smartButton('Dodaj', $this->url(array('controller' => 'event', 'action' => 'save'), 'admin', true));

function getInfoTypeDisplay($row) {
    $type = $row['type'];
    $data = My_Utils::getEventInfoTypes();
    if (isset($data[$type])) {
        return My_Utils::translate($data[$type]);
    }
    return $type;
}

function getPlaceTypeDisplay($row, $view) {
    $type = $row['type'];
    $data = My_Utils::getEventPlacesTypes();
    if (isset($data[$type])) {
        return My_Utils::translate($data[$type]);
    }
    return $type;
}

echo $this->table($this->list, array(
    'ID' => 'event_id',
    'Typ wydarzenia' => array('eval' => 'getInfoTypeDisplay($row)'),
    'Info' => 'info_name',
    'Miejsce' => 'place_name',
    'Adres' => array('${item.address} ${item.city}'),
    'Poczatek' => array('${item.start_date} ${item.start_time}'),
    'Koniec' => array('${item.end_date} ${item.end_time}'),
    'Operacje' => array(
        $this->smartButton('Wyświetl', $this->url(array('controller' => 'event', 'action' => 'show', 'id' => '${item.event_code}'), 'default', true), array('size' => 'mini'))
        .
        $this->smartButton('Edycja', $this->url(array('controller' => 'event', 'action' => 'save', 'id' => '${item.event_code}'), 'admin', true), array('size' => 'mini'))
        .
        $this->smartButton('Usuń', $this->url(array('controller' => 'event', 'action' => 'delete', 'id' => '${item.event_code}'), 'admin', true), array('size' => 'mini'))
    )
        )
);
?>